package cc.facesign.admin.expression;

import cc.facesign.admin.service.AclService;
import cc.facesign.admin.utils.PowerUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * springsecurity自定义权限校验相关方法
 */

@Component("ex")
public class SGExpressionRoot {

    @Autowired
    private AclService aclService;

    @Autowired
    private PowerUtils powerUtils;

    public boolean hasAuthorith(String authority) {
        String userId = powerUtils.getCurrentUser().getId();
        return aclService.getPerms(userId).contains(authority);
    }
}
